import { useState } from 'react'
import { useIsomorphicLayoutEffect } from './use-isomorphic-layout-effect'

export const useInnerVisible = (outerVisible: boolean): boolean => {
  const [innerVisible, setInnerVisible] = useState(outerVisible) // 初始永远是 false
  useIsomorphicLayoutEffect(() => {
    setInnerVisible(outerVisible) // 下一帧才同步
  }, [outerVisible])

  return innerVisible
}
